/**
 * Created by LiXiaoYan on 2017/06/20.
 */

'use.strict';
define(["app", "config", "service/service", "directive/headDir/headDir", 'angular-toastr', 'angular-toastr-tpls'], function(app, config) {
    app.register.controller('vinCarType', ['$scope', '$state', 'commonService', 'baserHttp', '$http', 'OEMIDTRUE', '$rootScope', '$location', '$stateParams', 'toastr', function($scope, $state, commonService, baserHttp, $http, OEMIDTRUE, $rootScope, $location, $stateParams, toastr) {
        $scope.param = {};
        $scope.vinSingle = {};
        if ($stateParams.vinCode) {
            var txtVIN = $stateParams.vinCode
            $scope.param['choice'] = 1;
            $scope.param['reqData'] = txtVIN;


            baserHttp.$httpPost('/search/inputbox.do', JSON.stringify($scope.param), function(data) {
                if (data.result) {
                    $scope.vinListNum = data.data;
                    if ($scope.vinListNum.length > 0) {
                        $scope.activeIndex = 0;
                        $scope.vinSingle = $scope.vinListNum[0];
                    } else {
                        alert('没有查到');
                    }

                }
            });
        };

        $scope.$on('vinListNum', function(e, data) {
            //获取Vin监听的相关数据
            $scope.vinListNum = data;
        });
        //$scope.vinSingle = $scope.vinListNum[0];
        $scope.activeBtn = function(item, index, e) {
            //点击列表加载相关数据填充table表格
            $scope.activeIndex = index;
            $scope.vinSingle = item;
        };
        $scope.vinSubmit = function() {
            //点击确定按钮给头部传递五级分类的ID和partsId
            $rootScope.vinSingle = $scope.vinSingle;
        }
    }])
})
